contact messages testing

jamesperet 9 years ago
parent
commit
3fc440f0ff

+ 1 - 1
app/views/contact_messages/_form.html.erb

@@ -7,7 +7,7 @@
7 7
 	<% end %>
8 8
 	<%= f.text_area :content, :label => (t 'contact.message'), :class => 'input-block-level', rows: '6'  %>
9 9
 
10
-	<%= f.button :submit, :value => (t 'contact.send') %>
10
+	<%= f.button :submit, :value => (t 'contact.send'), :id => 'submit_contact_message' %>
11 11
 	
12 12
  
13 13
 

+ 3 - 0
config/environments/test.rb

@@ -34,4 +34,7 @@ RailsWebsiteTemplate::Application.configure do
34 34
   # Print deprecation notices to the stderr.
35 35
   config.active_support.deprecation = :stderr
36 36
   
37
+  # Crapy Fix for email testing error
38
+  config.action_mailer.raise_delivery_errors = false
39
+  
37 40
 end

+ 0 - 1
features/blog.feature

@@ -9,7 +9,6 @@ Feature: Manage Articles
9 9
 	| Hello World | Welcome to the website | true      | First Post          | hello_world | 
10 10
 	| Test 001    | 1 2 3 testing          | true      | Testing the website | test_001    |
11 11
 
12
-	@focus	
13 12
 	Scenario: Blog posts list 
14 13
 		When I go to the blog page 
15 14
 		Then I should see "Hello World" 

+ 26 - 0
features/contact_messages.feature

@@ -0,0 +1,26 @@
1
+Feature: Contact Messages
2
+	In order to send a message
3
+	As an visitor
4
+	I want to send contact messages
5
+	
6
+	Scenario: Send Contact Message as a visitor
7
+		Given I go to the homepage
8
+		When I go to the contact page 
9
+		Then the page should have a "form" called "new_contact_message"
10
+		And I fill in "contact_message_email" with "yo@website.com"
11
+		And I fill in "contact_message_title" with "Hello Webmaster"
12
+		And I fill in "contact_message_content" with "How are you doing bro?"
13
+		And I click in the button "submit_contact_message"
14
+		Then I should see "Message sent!" 
15
+	
16
+	@focus
17
+	Scenario: Send Contact Message as a user
18
+		Given I am logged in as user
19
+		And I go to the homepage
20
+		When I go to the contact page 
21
+		Then the page should have a "form" called "new_contact_message"
22
+		And the page should not have a "input" called "contact_message_email"
23
+		And I fill in "contact_message_title" with "Hello Webmaster"
24
+		And I fill in "contact_message_content" with "How are you doing bro?"
25
+		And I click in the button "submit_contact_message"
26
+		Then I should see "Message sent!"

+ 10 - 18
features/step_definitions/blog_steps.rb

@@ -47,32 +47,24 @@ Then(/^I should see "(.*?)" And I should see "(.*?)"$/) do |arg1, arg2|
47 47
   page.should have_content(arg2)
48 48
 end
49 49
 
50
-When(/^I click in the link "(.*?)"$/) do |arg1|
51
-  click_link arg1
50
+Then(/^the page should have a "(.*?)" called "(.*?)"$/) do |arg1, arg2|
51
+  selector = arg1 + '#' + arg2
52
+  page.should have_css(selector)
52 53
 end
53 54
 
54
-When(/^I click in the button "(.*?)"$/) do |arg1|
55
-  click_button arg1
55
+Then(/^the page should not have a "(.*?)" called "(.*?)"$/) do |arg1, arg2|
56
+  selector = arg1 + '#' + arg2
57
+  page.should have_no_css(selector)
56 58
 end
57 59
 
58
-Given(/^I am logged in as admin$/) do
59
-  admin_login
60
+When(/^I click in the link "(.*?)"$/) do |arg1|
61
+  click_link arg1
60 62
 end
61 63
 
62
-Then(/^I log in as admin$/) do
63
-  admin_login
64
+When(/^I click in the button "(.*?)"$/) do |arg1|
65
+  click_button arg1
64 66
 end
65 67
 
66 68
 Then(/^I fill in "(.*?)" with "(.*?)"$/) do |arg1, arg2|
67 69
   fill_in arg1, :with => arg2
68 70
 end
69
-
70
-def admin_login
71
-  user = FactoryGirl.create(:admin)  
72
-  visit new_user_session_path  
73
-  fill_in "Email", :with => 'admin@website.com' 
74
-  fill_in "Password", :with => '12345678' 
75
-  click_button "Submit"
76
-  login_as user, scope: :user
77
-  visit root_path
78
-end

+ 31 - 0
features/step_definitions/login_steps.rb

@@ -0,0 +1,31 @@
1
+Given(/^I am logged in as user$/) do
2
+  user_login
3
+end
4
+
5
+Given(/^I am logged in as admin$/) do
6
+  admin_login
7
+end
8
+
9
+Then(/^I log in as admin$/) do
10
+  admin_login
11
+end
12
+
13
+def user_login
14
+  user = FactoryGirl.create(:user)  
15
+  visit new_user_session_path  
16
+  fill_in "Email", :with => 'johndoe@website.com' 
17
+  fill_in "Password", :with => '12345678' 
18
+  click_button "Submit"
19
+  login_as user, scope: :user
20
+  visit root_path
21
+end
22
+
23
+def admin_login
24
+  user = FactoryGirl.create(:admin)  
25
+  visit new_user_session_path  
26
+  fill_in "Email", :with => 'admin@website.com' 
27
+  fill_in "Password", :with => '12345678' 
28
+  click_button "Submit"
29
+  login_as user, scope: :user
30
+  visit root_path
31
+end

+ 3 - 0
features/support/paths.rb

@@ -10,6 +10,9 @@ module NavigationHelpers
10 10
     when/the blog page/ 
11 11
       visit blog_path 
12 12
       
13
+    when/the contact page/ 
14
+      visit contact_messages_path 
15
+      
13 16
     when/the admin blog posts page/
14 17
       visit admin_posts_path
15 18
       

+ 3 - 4
readme.md

@@ -10,8 +10,9 @@ A template for creating rails websites that includes the following:
10 10
 * Image upload/File System
11 11
 * Translation (pt-BR, EN)
12 12
 * Contact System
13
-- Maintaince Mode
13
+* Maintaince Mode
14 14
 * Email System (PaperClip + Mandrill)
15
+* Tests
15 16
 
16 17
 ## Installation
17 18
 
@@ -34,9 +35,8 @@ A template for creating rails websites that includes the following:
34 35
 
35 36
 ## Todo's
36 37
 
37
-- Google Analytics
38
+* Google Analytics
38 39
 * Log
39
-* Tests
40 40
 * Background processing (redis)
41 41
 * Search System
42 42
 * geo location/maps
@@ -45,7 +45,6 @@ A template for creating rails websites that includes the following:
45 45
 * Invite user/admin
46 46
 * admin panel tour
47 47
 * rewrite readme file
48
-* Install instructions
49 48
 * Heroku Deploy button
50 49
 * Wiki/Codex
51 50
 * Portfolio